'''
Author: your name
Date: 2020-11-05 11:40:19
LastEditTime: 2020-11-09 14:52:56
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\djangoS\app01\Models\models.py
'''
from django.db import models
from django.contrib.contenttypes.models import ContentType

class Book(models.Model):
    title = models.CharField(max_length=32)
    price = models.DecimalField(max_digits=5, decimal_places=2)
    pub_date = models.DateField()
    publish = models.ForeignKey("Publish1", on_delete=models.CASCADE)
    authors = models.ManyToManyField("Author1")

class Publish1(models.Model):
    name = models.CharField(max_length=32)
    city = models.CharField(max_length=64)
    email = models.EmailField()

class Author1(models.Model):
    name = models.CharField(max_length=32)
    age = models.SmallIntegerField()
    au_detail = models.OneToOneField("AuthorDetail1", on_delete=models.CASCADE)

class AuthorDetail1(models.Model):
    gender_choices = (
        (0, "女"),
        (1, "男"),
        (2, "保密"),
    )
    gender = models.SmallIntegerField(choices=gender_choices)
    tel = models.CharField(max_length=32)
    addrs = models.CharField(max_length=64)
    birthday = models.DateField()

class Emp(models.Model):
    name = models.CharField(max_length=32)
    age = models.IntegerField()
    salary = models.DecimalField(max_digits=8, decimal_places=2)
    dep = models.CharField(max_length=32)
    province = models.CharField(max_length=32)

class Emps(models.Model):
    name = models.CharField(max_length=32)
    age = models.IntegerField()
    salary =     models.DecimalField(max_digits=8, decimal_places=2)
    dep = models.ForeignKey("Dep", on_delete=models.CASCADE)
    province = models.CharField(max_length=32)

class Dep(models.Model):
    title = models.CharField(max_length=32)